<template>
	<view class="container">
		<!-- 渐变背景 -->
		<view class="gradient-background"></view>
		
		<!-- 自定义导航栏 -->
		<view class="custom-nav" :style="{ paddingTop: statusBarHeight + 'px' }">
			<view class="nav">
				<text class="nav-title">用户信息</text>
			</view>
		</view>
		
		<!-- 内容区域 -->
		<view class="content-wrapper">
			<!-- 用户信息卡片 -->
			<view class="user-card">
				<image class="avatar" src="/static/icon/touxiang.png" mode="aspectFill"></image>
				<view class="user-info">
					<text class="username">ZhuHao</text>
					<text class="user-type">普通用户</text>
				</view>
			</view>
			
			<!-- 学习统计 -->
			<view class="stats-section">
				<text class="section-title gray">学习统计</text>
				<view class="stats-item" style="margin-bottom: 5rpx;">
					<text class="label">生词本总数</text>
					<text class="value light">119</text>
				</view>
				<view class="stats-item" style="margin-bottom: 5rpx;">
					<text class="label">复习中单词</text>
					<text class="value blue light">119</text>
				</view>
				<view class="stats-item">
					<text class="label">已掌握单词</text>
					<text class="value green light">20</text>
				</view>
			</view>
			
			<!-- AI调用统计 -->
			<view class="stats-section">
				<text class="section-title gray">AI调用次数</text>
				<view class="stats-item" style="margin-bottom: 5rpx;">
					<text class="label">剩余调用次数</text>
					<text class="value light">119</text>
				</view>
				<view class="stats-item">
					<text class="label">购买</text>
					<image class="icon" src="/static/icon/shop.png" mode="aspectFit"></image>
				</view>
			</view>
			
			<!-- 退出登录 -->
			<view class="stats-item logout-section">
				<text class="label red">退出登录</text>
				<image class="icon" src="/static/icon/logout.png" mode="aspectFit"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusBarHeight: 0
			}
		},
		onLoad() {
			// 兼容微信小程序的方式获取状态栏高度
			const systemInfo = uni.getSystemInfoSync()
			this.statusBarHeight = systemInfo.statusBarHeight || 0
		}
	}
</script>

<style lang="scss">
.container {
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
	height: 100vh;
	background-color: #FFFFFF;
	position: relative;
	overflow: hidden; /* 去掉滚动条 */

	.gradient-background {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 40vh;
		background: linear-gradient(to bottom, #E4F2FF, #FFFFFF);
		z-index: 0;
	}

	.custom-nav {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		background-color: transparent;
		z-index: 100;

		.nav {
			width: 85%;
			height: 88rpx; /* 改为rpx单位 */
			margin: 50rpx 0rpx 0rpx 0rpx; /* 改为rpx单位 */
			display: flex;
			justify-content: flex-start;
			align-items: center;

			.nav-title {
				font-size: 36rpx; /* 改为rpx单位 */
				font-weight: bold;
				color: #333333;
				margin-left: 40rpx; /* 改为rpx单位 */
			}
		}
	}

	.content-wrapper {
		width: 90%;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-top: 180rpx; /* 避免被导航栏遮挡 */
		margin-top:60rpx;
	}

	.user-card {
		width: 90%;
		background: linear-gradient(to right, #3D9BEF, #00D0FF);
		border-radius: 24rpx; /* 改为rpx单位 */
		padding: 40rpx; /* 改为rpx单位 */
		display: flex;
		align-items: center;
		z-index: 1;
		box-shadow: 0 8rpx 24rpx rgba(61, 155, 239, 0.2); /* 改为rpx单位 */

		.avatar {
			width: 120rpx; /* 改为rpx单位 */
			height: 120rpx; /* 改为rpx单位 */
			border-radius: 60rpx; /* 改为rpx单位 */
			background-color: #FFFFFF;
		}

		.user-info {
			margin-left: 30rpx; /* 改为rpx单位 */
			display: flex;
			flex-direction: column;
			gap: 16rpx; /* 改为rpx单位 */

			.username {
				font-size: 40rpx; /* 改为rpx单位 */
				font-weight: bold;
				color: #FFFFFF;
			}

			.user-type {
				font-size: 28rpx; /* 改为rpx单位 */
				color: rgba(255, 255, 255, 0.8);
			}
		}
	}

	.stats-section {
		width: 100%;
		margin-top: 50rpx;
		z-index: 1;
		display: flex;
		flex-direction: column;
		align-items: center;

		.section-title {
			width: 100%;
			font-size: 32rpx;
			font-weight: bold;
			color: rgba(51, 51, 51, 0.6);
			margin-bottom: 30rpx;
			margin-left: 10rpx;
		}
	}

	.stats-item {
		width: 100%;
		background-color: #FFFFFF;
		border-radius: 24rpx;
		padding: 30rpx;
		margin: 5rpx auto;
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.08);
		box-sizing: border-box;

		.label {
			font-size: 30rpx;
			font-weight: 600;
			color: #333333;
		}

		.value {
			font-size: 30rpx;
			font-weight: bold;
			color: #333333;

			&.blue {
				color: #1079DA;
			}

			&.green {
				color: #34C759;
			}

			&.light {
				color: rgba(51, 51, 51, 0.6);
			}
		}

		.icon {
			width: 48rpx;
			height: 48rpx;
		}

		&.logout-section {
			margin-top: 40rpx;
			
			.label {
				color: #FF3B30;
				font-weight: 600;
			}
		}
	}
}
</style>